package com.ldd.mybatis.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ldd.mybatis.model.Emp;
import com.ldd.mybatis.model.MyApiResponse;
import com.ldd.mybatis.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @项目名： spring-emq
 * @包名： com.ldd.mybatis.controller
 * @文件名: EmpController
 * @创建者: liufudong@szyh-smart.com
 * @创建时间: 2024/10/12 19:42
 * @描述：
 */
@RestController
@Slf4j
public class EmpController {
    @Autowired
    private EmpService empService;
   //http://localhost:8045/findAllEmp?pageNum=1&pageSize=10
    @RequestMapping("/findAllEmp")
    public MyApiResponse<PageInfo<Emp>> findAllEmp(@RequestParam(defaultValue = "1")int pageNum,@RequestParam(defaultValue = "10") int pageSize) {
        log.info("findAllEmp,pageNum:{},pageSize:{}",pageNum,pageSize);
        // 启动分页
        PageHelper.startPage(pageNum,pageSize);
        List<Emp> empList= empService.empList();
        PageInfo<Emp> empPageInfo = new PageInfo<>(empList);
        return  MyApiResponse.success(empPageInfo);
    }

}
